package cn.com.css.taxInspection.common.sysjob.service;

import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
public class DynamicTaskInitializer implements ApplicationListener<ApplicationReadyEvent> {

    private final SchedulerService schedulerService;

    public DynamicTaskInitializer(SchedulerService schedulerService) {
        this.schedulerService = schedulerService;
    }

    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        schedulerService.init(); // 这里调用就不会报空指针
    }
}